<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#" class="back" onclick="history.go(-1)"/>Pesquisar Arquivo</h2>
        </ui:define>

        <ui:define name="body">
            <p:panel styleClass="container_24 clearfix">
                <div class="buttonAction" style="float: right">
                    <p:button value="Adicionar" href="criararquivo.xhtml" icon="ui-icon-plusthick"
                              styleClass="ui-priority-primary"/>
                </div>
                <br/>
            </p:panel>

            <h:form id="protocoloForm" enctype="multipart/form-data">            
                <p:messages id="messages" closable="true" showDetail="true" autoUpdate="true"  />
                <p:panel id="dadosGeraisPanel" styleClass="container_24 clearfix">
                    <h2>Filtros</h2>

                    <p:outputLabel value="Numero:" styleClass="grid_3" for="numeroInputText" />
                    <p:inputText id="numeroInputText" styleClass="grid_6" 
                                 value="#{managerPesquisarArquivo.protocoloPesquisar.numero}" />

                    <p:outputLabel value="Data:" styleClass="grid_3" for="dataCalendar" />
                    <p:calendar id="dataCalendar" value="#{managerPesquisarArquivo.protocoloPesquisar.dataProtocolo}"
                                showOn="both" locale="pt" yearRange="1900:2100" 
                                navigator="true" pattern="dd/MM/yyyy" styleClass="grid_8" />
                    <div class="clear"/>

                    <p:outputLabel value="Estante:" styleClass="grid_3" for="estanteInputText" />
                    <p:inputText id="estanteInputText" styleClass="grid_6"
                                 value="#{managerPesquisarArquivo.arquivoPesquisar.estante}" />

                    <p:outputLabel value="Caixa:" styleClass="grid_3" for="caixaInputText" />
                    <p:inputText id="caixaInputText" styleClass="grid_7"
                                 value="#{managerPesquisarArquivo.arquivoPesquisar.numCaixa}" />
                    <div class="clear"/>

                    <p:outputLabel value="Prateleira:" styleClass="grid_3" for="prateleiraInputText" />
                    <p:inputText id="prateleiraInputText" styleClass="grid_6"
                                 value="#{managerPesquisarArquivo.arquivoPesquisar.pratileira}" />

                    <br/>

                    <div class="clear-both" /><br />

                    <div class="buttonAction">
                        <p:commandButton value="Pesquisar" styleClass="ui-priority-primary"
                                         actionListener="#{managerPesquisarArquivo.pesquisar()}"
                                         update=":protocoloForm:protocolosPanel, :protocoloForm:protocolosTable"
                                         id="pesquisarCommandButton" icon="ui-icon-search"/>
                    </div>
                </p:panel> 

                <p:panel id="protocolosPanel" styleClass="container_24 clearfix">
                    <p:dataTable id="protocolosTable" var="item" value="#{managerPesquisarArquivo.protocolos}" 
                                 styleClass="grid_24" emptyMessage="Nenhum registro">  
                        <f:facet name="header">
                            Protocolos
                        </f:facet>

                        <p:column headerText="Ação" width="50">
                            <p:button title="Visualizar"
                                      href="visualizararquivo.xhtml?vArquivo=#{item.id}"
                                      icon="ui-icon-search"/>
                            <p:commandButton title="Excluir" 
                                             oncomplete="dlg.show();" 
                                             update="@form" 
                                             actionListener="#{managerPesquisarArquivo.setUsuariorr(item)}"
                                             icon="ui-icon-trash"/>

                        </p:column>

                        <p:column headerText="Número">  
                            #{item.numero}
                        </p:column>

                        <p:column headerText="Data">  
                            #{managerPesquisarArquivo.formantarDataProtocolo(item)}
                        </p:column> 
                        <p:column headerText="Estante">  
                            #{item.etiqueta.estante}
                        </p:column> 
                        <p:column headerText="Caixa">  
                            #{item.etiqueta.numCaixa}
                        </p:column> 
                        <p:column headerText="Prateleira">  
                            #{item.etiqueta.pratileira}
                        </p:column> 

                    </p:dataTable>

                    <div class="buttonAction">
                        <p:button value="Cancelar" icon="ui-icon-circle-close"
                                  href="indexarquivo.xhtml" /> 
                    </div>

                </p:panel>

            </h:form>
            <h:form>
                <p:panel id="paneldlg">
                    <p:dialog id="iddlg" header="Exclusão" widgetVar="dlg" modal="false"
                              showEffect="fade" hideEffect="fade" resizable="false" height="20">  
                        <h:outputText value="Deseja Excluir esse Registro ?" /> <br/> 
                        <f:facet name="footer">

                            <center>
                                <p:commandButton value="Sim" id="idb"
                                                 update="@form, :protocoloForm:protocolosTable"
                                                 icon="ui-icon-check"
                                                 actionListener="#{managerPesquisarArquivo.excluir()}"
                                                 />
                                <p:commandButton value="Não" process="@this" onclick="dlg.hide()" icon="ui-icon-close" />
                            </center>

                        </f:facet>
                    </p:dialog>   
                </p:panel>

            </h:form>

        </ui:define>
    </ui:composition>
</html>



